namespace EyeOpen.DddOrm.Domain.Factories
{
	using EyeOpen.Domain;

	public static class CategoryFactory
	{
		public static Category Create(string name)
		{
			return CreateInternal(null, name);
		}

		public static Category Create(string name, Category parent)
		{
			Ensure
				.That(parent, "parent")
				.IsNotNull();

			return CreateInternal(parent, name);
		}

		private static Category CreateInternal(Category parent, string name)
		{
			Ensure
				.That(name, "name")
				.IsNotNullOrWhiteSpace();

			return new Category { Parent = parent, Name = name }.SetId();
		}
	}
}